import {  ref,shallowReactive } from "vue";
import type {VNode,Component} from "vue"
import Menu from "../component/menu.vue";
import Main from "../main";


export default (main:Main) => {
    //
    const enabled = ref(true)
    
    // return r as IMenu;
    const title = shallowReactive<(VNode|Component|string)[]>([])
    const resetTitle = (t:VNode|Component|string|(VNode|Component|string)[]) => {
        title.length = 0;
        title.push(...new Array().concat(t))
        if(typeof t === 'string'){
            resetName(t)
        }
    }
    //
    const name = ref("");
    const resetName = (s:string) => {
        name.value = s;
    }
    //
    const operates = shallowReactive<(VNode|Component)[]>([])
    const resetOperates = (ops:VNode|Component|(VNode|Component)[]) => {
        operates.length = 0;
        operates.push(...new Array().concat(ops))
    }
    //
    return {
        enabled,
        //
        Menu,
        props:{main,title,operates },
        //
        title,
        resetTitle,
        name,
        resetName,
        resetOperates
    }

}